package dome1;

import java.util.*;

public class Text {
    public static void main(String[] args) {
        Map<String,Integer> map = new HashMap<>();
    }
    public int singleNumber(int[] nums) {
        String str = "afsaf";
        for (char c : str.toCharArray()) {
            
        }

        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if (!set.contains(nums[i])) {
                set.add(nums[i]);
            } else {
                set.remove(nums[i]);
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])) {
                return nums[i];
            }
        }
        return -1;
    }

    public int numJewelsInStones(String jewels, String stones) {
        Set<Character> set = new HashSet<>();
        int count = 0;
        for(int i = 0;i<jewels.length();i++) {
            char ch = jewels.charAt(i);
            set.add(ch);
        }
        for(int i = 0;i<stones.length();i++) {
            char ch = stones.charAt(i);
            if(set.contains(ch)) {
                count++;
            }
        }
        return count;
    }
}



/*
// Definition for a Node.
class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }
}
*/
//class Solution {
//    public Node copyRandomList(Node head) {
//        Map<Node,Node> map = new HashMap<>();
//        Node cur = head;
//        while(cur!=null) {
//            Node node = new Node(cur.val);
//            map.put(cur,node);
//            cur = cur.next;
//        }
//        cur = head;
//        while(cur!=null) {
//            map.get(cur).next = map.get(cur.next);
//            map.get(cur).random = map.get(cur.random);
//            cur = cur.next;
//        }
//        return map.get(head);
//    }
//}
